package sandbox.vaadin;

import javax.ejb.EJB;

import sandbox.session.DefaultSessionContext;
import sandbox.vaadin.Util.Size;
import sandbox.vaadin.skiller.MutableLocalEntityProviderSkillSSB;
import sandbox.vaadin.skiller.MutableLocalEntityProviderSkillgroupSSB;
import sandbox.vaadin.skiller.entity.SkillgroupDAOSSB;

import com.vaadin.annotations.Theme;
import com.vaadin.cdi.CDIUI;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;

@Theme("sandbox_vaadin")
@CDIUI
public class SandboxVaadinUI extends UI
{
  private static final long serialVersionUID = 1L;

	public final static String PERSISTENCE_UNIT = "sandbox.vaadin";

//	@WebServlet(value = "/*", asyncSupported = true)
//	@VaadinServletConfiguration(productionMode = false, ui = SandboxVaadinUI.class, widgetset = "sandbox.vaadin.widgetset.Sandbox_vaadinWidgetset")
//	public static class Servlet extends VaadinServlet { }
	
	@EJB
//	@Inject
	private SkillgroupDAOSSB skillgroupDAOSSB;
	
	@EJB
//@Inject
	private MutableLocalEntityProviderSkillgroupSSB skillgroupEntityProviderSSB;
	
	@EJB
//@Inject
	private MutableLocalEntityProviderSkillSSB skillEntityProviderSSB;

	@Override
	protected void init(VaadinRequest request)
	{
//		LOGGER.debug("skillgroupDAOSSB == null: " + (skillgroupDAOSSB == null));
//		LOGGER.debug("skillgroupEntityProviderSSB == null: " + (skillgroupEntityProviderSSB == null));
		Util.setSize(this, Size.FULL);

		DefaultSessionContext defaultSessionContext = new DefaultSessionContext();
		defaultSessionContext.setSkillgroupDAO(skillgroupDAOSSB);
		defaultSessionContext.setSkillgroupEntityProvider(skillgroupEntityProviderSSB);
		defaultSessionContext.setSkillEntityProvider(skillEntityProviderSSB);

		MainView mainView = new MainView(Size.FULL);

		setContent(mainView);
	}
}